#include <stdio.h>
#include <uv.h>
#include <unistd.h>

int64_t counter = 0;
void wait_for_a_while(uv_idle_t* handle)
{
    counter++;
    sleep(1);

    printf("--%ld\n", counter);
    if(counter >= 10) {
        counter = 0;
        uv_idle_stop(handle);
    }
}

int main(int argc, char **argv)
{
    uv_idle_t idler;

    uv_idle_init(uv_default_loop(), &idler);

    while(true) {
        printf("aaaaaa\n");
        printf("Idling...\n");
        uv_idle_start(&idler, wait_for_a_while);
        uv_run(uv_default_loop(), UV_RUN_DEFAULT);

    }

    return 0;
}
